<?php

namespace App\Admin\Controllers;

use App\Models\OrderPingan;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class OrderPinganController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'OrderPingan';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new OrderPingan());

        $grid->column('id', __('Id'));
        $grid->column('serial_number', '流水号');
        // $grid->column('user_id', __('User id'));
        $grid->column('phone_number', '手机号');
        $grid->column('package_id', '权益报');
        $grid->column('price', '价格');
        $grid->column('created_at', '订单时间')->date("Y-m-d H:i:s");

        $grid->filter(function($filter){
            // Remove the default id filter
            $filter->disableIdFilter();
            // Add a column filter
            $filter->equal('package_id', '权益包')->select(['1' => '1', '2' => '2', '3' => '3', '4' => '4']);
            $filter->like('phone_number', '手机号');
            $filter->between('created_at', '订单时间')->datetime();
        });


        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(OrderPingan::findOrFail($id));


        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new OrderPingan());


        return $form;
    }
}
